#-*- coding: utf-8 -*-

from models import Article
from django.core.urlresolvers import reverse
from django.views.generic import ListView, CreateView 
from django.core.mail import send_mail
 
class NewArticleView(CreateView):
    model = Article
    template_name = 'catalog/create_article.html'
    
    def get_success_url(self):
        return reverse('home')
    
    def post(self, request, *args, **kwargs):
        
        #https://docs.djangoproject.com/en/dev/topics/email/
        send_mail('Article en cours de validation', 'Votre article est en cours de validation ', 'from@example.com',['to@example.com'], fail_silently=False)
        return 

    
class CatalogView(ListView):
    model = Article
    context_object_name = 'articles'
    template_name = 'catalog/catalog.html'
    paginate_by = 3